#include <QApplication>
#include <QMainWindow>
#include <QTextCodec>

#include "chess_window.h"


#define CUI         0
#define GUI         1
#define UI_MODE     GUI

#if 1
int main(int argc, char *argv[])
{
// CUI
#if (UI_MODE == CUI)
    return 0;

// GUI
#elif (UI_MODE == GUI)
    QApplication app(argc, argv);
    ChessWindow window;
    QTextCodec *pCodec = NULL;
    
    // 中文支持
    pCodec = QTextCodec::codecForName("SYSTEM");
    QTextCodec::setCodecForLocale(pCodec);
    QTextCodec::setCodecForCStrings(pCodec);
    QTextCodec::setCodecForTr(pCodec);

    // 显示主窗口
    window.show();

    return app.exec();

// error
#else
    #error "unknown UI_MODE value!"
#endif
}
#else

#include  < QApplication > 
#include  < QtGui >
#include <QFrame>

int  main( int  argc,  char   * argv[])
{
    QApplication app(argc,argv);

    QFrame  * frame  =   new  QFrame;
    frame -> resize( 400 , 700 );
    QPixmap pixmap(QString::fromUtf8(":/images/bk.bmp"));
    QPalette   palette;
    palette.setBrush(frame -> backgroundRole(),QBrush( pixmap ));
    frame -> setPalette(palette);
    frame->setMask(pixmap.createMaskFromColor(QColor(0, 255, 0)));  //可以将图片中透明部分显示为透明的
    frame -> setAutoFillBackground( true );
    frame -> show();

    return  app.exec();
}
#endif

#ifndef UI_MODE
    #error "macro UI_MODE undefined!"
#endif
